<?php
namespace app\common\model;

use think\Model;

class Carmanage extends Model
{
    //车辆列表
    public function carstatuslist($field,$page,$limit){
        $list = db('car')
            ->alias('c')
            ->field($field)
            ->join('store s' ,"c.store_id = s.store_id",'left')
            ->join('company co',"co.company_id = c.company_id",'left')
            //->join('company_car cr','cr.')
            ->page($page,$limit)
            ->order('c.car_id desc')
            ->select();
        $count = db('car')
            ->alias('c')
            ->join('store s' ,"c.store_id = s.store_id",'left')
            ->join('company co',"co.company_id = c.company_id",'left')
            ->count();
        return ['count' => $count,'data' => $list];
    }
    //私家车审核列表
    public function oneselfcar($page,$limit){
        $list = db('oneselfcar')
            ->alias('o')
            ->field('o.oneselfcar_id,o.oneselfcar_plate,o.oneselfcar_name,from_unixtime(o.oneselfcar_seeworldtime,\'%Y .%m .%d %H:%i:%s\') create_date,o.oneselfcar_mastername,o.oneselfcar_card,oneselfcar_status')
            ->order('oneselfcar_id desc')
            ->page($page,$limit)
            ->select();
        $count = db('oneselfcar')
            ->select();
        return ['count' => $count,'data' => $list];
    }
    //车型管理
    public function cartype(){
        $list = db('cartype')
            ->where('cartype_status',1)
            ->select();
        $count = db('cartype')
            ->where('cartype_status',1)
            ->count();
        foreach ($list as $v=>$k){
            $list[$v]['pidname'] = db('cartype')->where('cartype_id',$list[$v]['pid'])->value('cartype_what');
        }
        return ['count' => $count,'data' => $list];
    }
    public function gettypelist($where){
        $list = db('cartype')
            ->where($where)
            ->where('cartype_status',1)
            ->select();
        return $list;
    }

}